{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# pandas：找出、删除重复的数据（Python）\n",
    "\n",
    "- 1.duplicated()\n",
    "- 2.drop_duplicates()\n",
    "* https://blog.csdn.net/weixin_43887421/article/details/114926685\n",
    "- https://blog.csdn.net/lzx159951/article/details/104352842\n",
    "\n",
    "## duplicated()\n",
    "duplicated()可以被用在DataFrame的三种情况下，分别是pandas.DataFrame.duplicated、pandas.Series.duplicated和pandas.Index.duplicated。他们的用法都类似，前两个会返回一个布尔值的Series，最后一个会返回一个布尔值的numpy.ndarray。\n",
    "\n",
    "## drop_duplicates()\n",
    "与duplicated()类似，drop_duplicates()是直接把重复值给删掉。下面只会介绍一些含义不同的参数。\n",
    "\n",
    "DataFrame.drop_duplicates(subset=None, keep=‘first’, inplace=False)\n",
    "subset：与duplicated()中相同\n",
    "keep：与duplicated()中相同\n",
    "inplace：与pandas其他函数的inplace相同，选择是修改现有数据还是返回新的数据\n",
    "\n",
    "\n",
    "df.drop_duplicates(subset=[‘name1’,‘name2’],keep=‘first’,inplace=True)这个是最关键的语句了。\n",
    "首先subset参数是一个列表，这个列表是需要你填进行相同数据判断的条件。就比如我选的条件是method和year，即 method值和year的值相同就可被判定为一样的数据。keep的取值有三个 分别是 first、last、false\n",
    "`keep=first`时，保留相同数据的第一条。keep=last时，保存相同数据的最后一条。keep=false时，所有相同的数据都不保留。inplace=True时，会对原数据进行修改。否则，只返回视图，不对原数据修改。\n",
    "\n",
    "\n",
    "# pandas显示所有行/列以及设置value显示的长度\n",
    "- #设置value的显示长度为200，默认为50\n",
    ">pd.set_option('max_colwidth',200)\n",
    "- #显示所有列，把行显示设置成最大\n",
    ">pd.set_option('display.max_columns', None)\n",
    "- #显示所有行，把列显示设置成最大\n",
    ">pd.set_option('display.max_rows', None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "         经度     纬度   降雨量         站名\n",
      "0    122.94  42.48  13.1       包家屯镇\n",
      "1    123.04  41.97  12.8        兴隆镇\n",
      "2    123.23  42.63  12.5       方家屯镇\n",
      "3    123.11  42.08  12.5      三道岗子镇\n",
      "4    122.89  42.67  12.1       沙金台乡\n",
      "..      ...    ...   ...        ...\n",
      "234  123.35  42.71   1.8       东关街道\n",
      "235  122.76  41.56   1.2       蒲西街道\n",
      "236  123.58  42.03   0.8  清水台街道小洋河村\n",
      "237  122.55  41.59   0.0       牛心坨镇\n",
      "238  123.22  42.06   0.0       罗家房镇\n",
      "\n",
      "[239 rows x 4 columns]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from pandas import Series, DataFrame\n",
    "# pd.set_option('display.max_rows', None) #显示所有的行\n",
    "\n",
    "df = pd.read_csv('E:/Python绘制降雨等值线图20211223/shenyangyl.csv',header=None,names=['经度','纬度','降雨量','站名'],encoding=\"gbk\")\n",
    "print(df)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>经度</th>\n",
       "      <th>纬度</th>\n",
       "      <th>降雨量</th>\n",
       "      <th>站名</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>122.94</td>\n",
       "      <td>42.48</td>\n",
       "      <td>13.1</td>\n",
       "      <td>包家屯镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>123.04</td>\n",
       "      <td>41.97</td>\n",
       "      <td>12.8</td>\n",
       "      <td>兴隆镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>123.23</td>\n",
       "      <td>42.63</td>\n",
       "      <td>12.5</td>\n",
       "      <td>方家屯镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>123.11</td>\n",
       "      <td>42.08</td>\n",
       "      <td>12.5</td>\n",
       "      <td>三道岗子镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>122.89</td>\n",
       "      <td>42.67</td>\n",
       "      <td>12.1</td>\n",
       "      <td>沙金台乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>234</th>\n",
       "      <td>123.35</td>\n",
       "      <td>42.71</td>\n",
       "      <td>1.8</td>\n",
       "      <td>东关街道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>235</th>\n",
       "      <td>122.76</td>\n",
       "      <td>41.56</td>\n",
       "      <td>1.2</td>\n",
       "      <td>蒲西街道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>236</th>\n",
       "      <td>123.58</td>\n",
       "      <td>42.03</td>\n",
       "      <td>0.8</td>\n",
       "      <td>清水台街道小洋河村</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>237</th>\n",
       "      <td>122.55</td>\n",
       "      <td>41.59</td>\n",
       "      <td>0.0</td>\n",
       "      <td>牛心坨镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>238</th>\n",
       "      <td>123.22</td>\n",
       "      <td>42.06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>罗家房镇</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>239 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         经度     纬度   降雨量         站名\n",
       "0    122.94  42.48  13.1       包家屯镇\n",
       "1    123.04  41.97  12.8        兴隆镇\n",
       "2    123.23  42.63  12.5       方家屯镇\n",
       "3    123.11  42.08  12.5      三道岗子镇\n",
       "4    122.89  42.67  12.1       沙金台乡\n",
       "..      ...    ...   ...        ...\n",
       "234  123.35  42.71   1.8       东关街道\n",
       "235  122.76  41.56   1.2       蒲西街道\n",
       "236  123.58  42.03   0.8  清水台街道小洋河村\n",
       "237  122.55  41.59   0.0       牛心坨镇\n",
       "238  123.22  42.06   0.0       罗家房镇\n",
       "\n",
       "[239 rows x 4 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      False\n",
       "1      False\n",
       "2      False\n",
       "3      False\n",
       "4      False\n",
       "       ...  \n",
       "234    False\n",
       "235    False\n",
       "236    False\n",
       "237    False\n",
       "238    False\n",
       "Length: 239, dtype: bool"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.duplicated(subset=['经度','纬度'],keep='first')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 完全去重"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>经度</th>\n",
       "      <th>纬度</th>\n",
       "      <th>降雨量</th>\n",
       "      <th>站名</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>122.94</td>\n",
       "      <td>42.48</td>\n",
       "      <td>13.1</td>\n",
       "      <td>包家屯镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>123.04</td>\n",
       "      <td>41.97</td>\n",
       "      <td>12.8</td>\n",
       "      <td>兴隆镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>123.23</td>\n",
       "      <td>42.63</td>\n",
       "      <td>12.5</td>\n",
       "      <td>方家屯镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>123.11</td>\n",
       "      <td>42.08</td>\n",
       "      <td>12.5</td>\n",
       "      <td>三道岗子镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>122.89</td>\n",
       "      <td>42.67</td>\n",
       "      <td>12.1</td>\n",
       "      <td>沙金台乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>234</th>\n",
       "      <td>123.35</td>\n",
       "      <td>42.71</td>\n",
       "      <td>1.8</td>\n",
       "      <td>东关街道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>235</th>\n",
       "      <td>122.76</td>\n",
       "      <td>41.56</td>\n",
       "      <td>1.2</td>\n",
       "      <td>蒲西街道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>236</th>\n",
       "      <td>123.58</td>\n",
       "      <td>42.03</td>\n",
       "      <td>0.8</td>\n",
       "      <td>清水台街道小洋河村</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>237</th>\n",
       "      <td>122.55</td>\n",
       "      <td>41.59</td>\n",
       "      <td>0.0</td>\n",
       "      <td>牛心坨镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>238</th>\n",
       "      <td>123.22</td>\n",
       "      <td>42.06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>罗家房镇</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>239 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         经度     纬度   降雨量         站名\n",
       "0    122.94  42.48  13.1       包家屯镇\n",
       "1    123.04  41.97  12.8        兴隆镇\n",
       "2    123.23  42.63  12.5       方家屯镇\n",
       "3    123.11  42.08  12.5      三道岗子镇\n",
       "4    122.89  42.67  12.1       沙金台乡\n",
       "..      ...    ...   ...        ...\n",
       "234  123.35  42.71   1.8       东关街道\n",
       "235  122.76  41.56   1.2       蒲西街道\n",
       "236  123.58  42.03   0.8  清水台街道小洋河村\n",
       "237  122.55  41.59   0.0       牛心坨镇\n",
       "238  123.22  42.06   0.0       罗家房镇\n",
       "\n",
       "[239 rows x 4 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop_duplicates()   # 完全去重"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  对某几列相同的去重"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>经度</th>\n",
       "      <th>纬度</th>\n",
       "      <th>降雨量</th>\n",
       "      <th>站名</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>122.94</td>\n",
       "      <td>42.48</td>\n",
       "      <td>13.1</td>\n",
       "      <td>包家屯镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>123.04</td>\n",
       "      <td>41.97</td>\n",
       "      <td>12.8</td>\n",
       "      <td>兴隆镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>123.23</td>\n",
       "      <td>42.63</td>\n",
       "      <td>12.5</td>\n",
       "      <td>方家屯镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>123.11</td>\n",
       "      <td>42.08</td>\n",
       "      <td>12.5</td>\n",
       "      <td>三道岗子镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>122.89</td>\n",
       "      <td>42.67</td>\n",
       "      <td>12.1</td>\n",
       "      <td>沙金台乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>234</th>\n",
       "      <td>123.35</td>\n",
       "      <td>42.71</td>\n",
       "      <td>1.8</td>\n",
       "      <td>东关街道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>235</th>\n",
       "      <td>122.76</td>\n",
       "      <td>41.56</td>\n",
       "      <td>1.2</td>\n",
       "      <td>蒲西街道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>236</th>\n",
       "      <td>123.58</td>\n",
       "      <td>42.03</td>\n",
       "      <td>0.8</td>\n",
       "      <td>清水台街道小洋河村</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>237</th>\n",
       "      <td>122.55</td>\n",
       "      <td>41.59</td>\n",
       "      <td>0.0</td>\n",
       "      <td>牛心坨镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>238</th>\n",
       "      <td>123.22</td>\n",
       "      <td>42.06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>罗家房镇</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>239 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         经度     纬度   降雨量         站名\n",
       "0    122.94  42.48  13.1       包家屯镇\n",
       "1    123.04  41.97  12.8        兴隆镇\n",
       "2    123.23  42.63  12.5       方家屯镇\n",
       "3    123.11  42.08  12.5      三道岗子镇\n",
       "4    122.89  42.67  12.1       沙金台乡\n",
       "..      ...    ...   ...        ...\n",
       "234  123.35  42.71   1.8       东关街道\n",
       "235  122.76  41.56   1.2       蒲西街道\n",
       "236  123.58  42.03   0.8  清水台街道小洋河村\n",
       "237  122.55  41.59   0.0       牛心坨镇\n",
       "238  123.22  42.06   0.0       罗家房镇\n",
       "\n",
       "[239 rows x 4 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop_duplicates(subset=['经度','纬度','站名'],keep='first',inplace=False) #['经度','纬度','站名'三列相同的去重"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>经度</th>\n",
       "      <th>纬度</th>\n",
       "      <th>降雨量</th>\n",
       "      <th>站名</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>122.94</td>\n",
       "      <td>42.48</td>\n",
       "      <td>13.1</td>\n",
       "      <td>包家屯镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>123.04</td>\n",
       "      <td>41.97</td>\n",
       "      <td>12.8</td>\n",
       "      <td>兴隆镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>123.23</td>\n",
       "      <td>42.63</td>\n",
       "      <td>12.5</td>\n",
       "      <td>方家屯镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>123.11</td>\n",
       "      <td>42.08</td>\n",
       "      <td>12.5</td>\n",
       "      <td>三道岗子镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>122.89</td>\n",
       "      <td>42.67</td>\n",
       "      <td>12.1</td>\n",
       "      <td>沙金台乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>234</th>\n",
       "      <td>123.35</td>\n",
       "      <td>42.71</td>\n",
       "      <td>1.8</td>\n",
       "      <td>东关街道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>235</th>\n",
       "      <td>122.76</td>\n",
       "      <td>41.56</td>\n",
       "      <td>1.2</td>\n",
       "      <td>蒲西街道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>236</th>\n",
       "      <td>123.58</td>\n",
       "      <td>42.03</td>\n",
       "      <td>0.8</td>\n",
       "      <td>清水台街道小洋河村</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>237</th>\n",
       "      <td>122.55</td>\n",
       "      <td>41.59</td>\n",
       "      <td>0.0</td>\n",
       "      <td>牛心坨镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>238</th>\n",
       "      <td>123.22</td>\n",
       "      <td>42.06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>罗家房镇</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>234 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         经度     纬度   降雨量         站名\n",
       "0    122.94  42.48  13.1       包家屯镇\n",
       "1    123.04  41.97  12.8        兴隆镇\n",
       "2    123.23  42.63  12.5       方家屯镇\n",
       "3    123.11  42.08  12.5      三道岗子镇\n",
       "4    122.89  42.67  12.1       沙金台乡\n",
       "..      ...    ...   ...        ...\n",
       "234  123.35  42.71   1.8       东关街道\n",
       "235  122.76  41.56   1.2       蒲西街道\n",
       "236  123.58  42.03   0.8  清水台街道小洋河村\n",
       "237  122.55  41.59   0.0       牛心坨镇\n",
       "238  123.22  42.06   0.0       罗家房镇\n",
       "\n",
       "[234 rows x 4 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop_duplicates(subset=['经度','纬度'],keep='first',inplace=False) #对'经度','纬度',相同的去重"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      False\n",
       "1      False\n",
       "2      False\n",
       "3      False\n",
       "4      False\n",
       "       ...  \n",
       "234    False\n",
       "235    False\n",
       "236    False\n",
       "237    False\n",
       "238    False\n",
       "Length: 239, dtype: bool"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.duplicated(subset=['经度','纬度'],keep='first') #对'经度','纬度',相同的去重"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      False\n",
       "1      False\n",
       "2      False\n",
       "3      False\n",
       "4      False\n",
       "       ...  \n",
       "234    False\n",
       "235    False\n",
       "236    False\n",
       "237    False\n",
       "238    False\n",
       "Length: 239, dtype: bool"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.duplicated( keep=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 取出重复的值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>经度</th>\n",
       "      <th>纬度</th>\n",
       "      <th>降雨量</th>\n",
       "      <th>站名</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>123.42</td>\n",
       "      <td>41.84</td>\n",
       "      <td>9.8</td>\n",
       "      <td>北陵公园</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>123.42</td>\n",
       "      <td>41.80</td>\n",
       "      <td>9.8</td>\n",
       "      <td>八一公园</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>123.31</td>\n",
       "      <td>41.80</td>\n",
       "      <td>9.3</td>\n",
       "      <td>苗圃</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>123.47</td>\n",
       "      <td>41.81</td>\n",
       "      <td>9.1</td>\n",
       "      <td>大东文化馆</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>123.47</td>\n",
       "      <td>41.81</td>\n",
       "      <td>8.7</td>\n",
       "      <td>沈阳五中</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>112</th>\n",
       "      <td>123.42</td>\n",
       "      <td>41.84</td>\n",
       "      <td>8.1</td>\n",
       "      <td>北陵公园泵站</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>115</th>\n",
       "      <td>123.31</td>\n",
       "      <td>41.80</td>\n",
       "      <td>8.0</td>\n",
       "      <td>苗圃泵站</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>118</th>\n",
       "      <td>123.42</td>\n",
       "      <td>41.80</td>\n",
       "      <td>8.0</td>\n",
       "      <td>北市场</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>155</th>\n",
       "      <td>123.52</td>\n",
       "      <td>41.81</td>\n",
       "      <td>7.4</td>\n",
       "      <td>东陵街道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>166</th>\n",
       "      <td>123.52</td>\n",
       "      <td>41.81</td>\n",
       "      <td>7.2</td>\n",
       "      <td>八家子泵站</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         经度     纬度  降雨量      站名\n",
       "36   123.42  41.84  9.8    北陵公园\n",
       "39   123.42  41.80  9.8    八一公园\n",
       "49   123.31  41.80  9.3      苗圃\n",
       "56   123.47  41.81  9.1   大东文化馆\n",
       "87   123.47  41.81  8.7    沈阳五中\n",
       "112  123.42  41.84  8.1  北陵公园泵站\n",
       "115  123.31  41.80  8.0    苗圃泵站\n",
       "118  123.42  41.80  8.0     北市场\n",
       "155  123.52  41.81  7.4    东陵街道\n",
       "166  123.52  41.81  7.2   八家子泵站"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# duplicate_bool = df.duplicated(subset=['经度','纬度'], keep='first') \n",
    "duplicate_bool = df.duplicated(subset=['经度','纬度'], keep=False)\n",
    "repeat=df.loc[duplicate_bool == True]\n",
    "repeat"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Pandas常用功能使用总结\n",
    "https://zhuanlan.zhihu.com/p/113174935\n",
    "\n",
    "https://zhuanlan.zhihu.com/p/113174935"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 239 entries, 0 to 238\n",
      "Data columns (total 4 columns):\n",
      " #   Column  Non-Null Count  Dtype  \n",
      "---  ------  --------------  -----  \n",
      " 0   经度      239 non-null    float64\n",
      " 1   纬度      239 non-null    float64\n",
      " 2   降雨量     239 non-null    float64\n",
      " 3   站名      239 non-null    object \n",
      "dtypes: float64(3), object(1)\n",
      "memory usage: 7.6+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info() #查看数据的基本信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>经度</th>\n",
       "      <th>纬度</th>\n",
       "      <th>降雨量</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>239.000000</td>\n",
       "      <td>239.000000</td>\n",
       "      <td>239.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>123.302259</td>\n",
       "      <td>41.939289</td>\n",
       "      <td>7.800837</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.286240</td>\n",
       "      <td>0.357585</td>\n",
       "      <td>2.224161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>122.480000</td>\n",
       "      <td>41.250000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>123.180000</td>\n",
       "      <td>41.705000</td>\n",
       "      <td>6.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>123.370000</td>\n",
       "      <td>41.820000</td>\n",
       "      <td>7.900000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>123.475000</td>\n",
       "      <td>42.060000</td>\n",
       "      <td>9.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>123.950000</td>\n",
       "      <td>42.940000</td>\n",
       "      <td>13.100000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               经度          纬度         降雨量\n",
       "count  239.000000  239.000000  239.000000\n",
       "mean   123.302259   41.939289    7.800837\n",
       "std      0.286240    0.357585    2.224161\n",
       "min    122.480000   41.250000    0.000000\n",
       "25%    123.180000   41.705000    6.800000\n",
       "50%    123.370000   41.820000    7.900000\n",
       "75%    123.475000   42.060000    9.100000\n",
       "max    123.950000   42.940000   13.100000"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe() #「查看数据的统计信息」"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "123.35    11\n",
       "123.42     9\n",
       "123.40     8\n",
       "123.38     8\n",
       "123.36     7\n",
       "          ..\n",
       "122.98     1\n",
       "123.25     1\n",
       "123.16     1\n",
       "123.95     1\n",
       "123.22     1\n",
       "Name: 经度, Length: 96, dtype: int64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#「查看某列各属性个数」\n",
    "df['经度'].value_counts()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "122.94     1\n",
       "122.79     1\n",
       "122.66     1\n",
       "122.62     1\n",
       "123.29     1\n",
       "          ..\n",
       "123.36     7\n",
       "123.40     8\n",
       "123.38     8\n",
       "123.42     9\n",
       "123.35    11\n",
       "Name: 经度, Length: 96, dtype: int64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['经度'].value_counts(ascending=True) #指定按照个数从少到多排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['经度', '纬度', '降雨量', '站名'], dtype='object')"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns #获取数据的列名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=239, step=1)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index #获取数据的索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "经度     float64\n",
       "纬度     float64\n",
       "降雨量    float64\n",
       "站名      object\n",
       "dtype: object"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes #获取每列数据对应的数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[122.94, 42.48, 13.1, '包家屯镇'],\n",
       "       [123.04, 41.97, 12.8, '兴隆镇'],\n",
       "       [123.23, 42.63, 12.5, '方家屯镇'],\n",
       "       [123.11, 42.08, 12.5, '三道岗子镇'],\n",
       "       [122.89, 42.67, 12.1, '沙金台乡'],\n",
       "       [123.13, 42.66, 11.8, '东升乡'],\n",
       "       [122.88, 42.33, 11.6, '叶茂台镇'],\n",
       "       [123.12, 42.28, 11.3, '登仕堡子镇'],\n",
       "       [123.0, 42.16, 11.2, '公主屯镇'],\n",
       "       [123.07, 41.91, 11.2, '兴隆堡镇'],\n",
       "       [123.75, 41.99, 11.2, '森林公园'],\n",
       "       [123.18, 42.18, 11.1, '陶家屯镇'],\n",
       "       [122.99, 42.23, 10.9, '新农乡'],\n",
       "       [122.97, 41.84, 10.9, '大民屯镇'],\n",
       "       [122.72, 41.93, 10.9, '柳河沟镇'],\n",
       "       [122.69, 41.79, 10.9, '金五台子镇'],\n",
       "       [122.87, 41.78, 10.9, '前当堡镇'],\n",
       "       [122.78, 42.18, 10.7, '大柳屯镇'],\n",
       "       [123.05, 42.52, 10.7, '卧牛石乡'],\n",
       "       [123.11, 42.17, 10.6, '东蛇山子镇'],\n",
       "       [123.14, 41.59, 10.5, '永乐街道'],\n",
       "       [123.3, 41.55, 10.5, '八一红菱街道北红菱村'],\n",
       "       [122.85, 41.96, 10.5, '新民'],\n",
       "       [123.65, 41.86, 10.4, '沈阳世博园'],\n",
       "       [123.42, 41.7, 10.4, '西区泵站'],\n",
       "       [123.69, 41.86, 10.4, '高坎街道'],\n",
       "       [123.0, 41.83, 10.3, '张家屯镇'],\n",
       "       [123.17, 41.78, 10.3, '沙岭街道'],\n",
       "       [123.19, 41.95, 10.3, '光辉街道'],\n",
       "       [122.65, 41.67, 10.2, '老大房镇'],\n",
       "       [123.4, 41.89, 10.2, '三台子立交'],\n",
       "       [123.3, 42.2, 10.1, '三面船镇'],\n",
       "       [123.76, 41.99, 10.0, '古砬子社区'],\n",
       "       [123.26, 41.56, 9.9, '八一红菱街道宛庄村'],\n",
       "       [123.79, 41.77, 9.9, '中华寺景区'],\n",
       "       [123.27, 41.78, 9.8, '张士开发区'],\n",
       "       [123.42, 41.84, 9.8, '北陵公园'],\n",
       "       [123.75, 41.71, 9.8, '王滨街道'],\n",
       "       [123.36, 41.83, 9.8, '朝鲜一中'],\n",
       "       [123.42, 41.8, 9.8, '八一公园'],\n",
       "       [122.79, 41.7, 9.7, '冷子堡镇'],\n",
       "       [123.43, 41.96, 9.7, '方特欢乐世界'],\n",
       "       [123.34, 42.56, 9.6, '慈恩寺乡'],\n",
       "       [122.64, 42.06, 9.5, '梁山镇'],\n",
       "       [123.46, 41.74, 9.5, '奥体中心'],\n",
       "       [123.26, 41.55, 9.4, '八一红菱街道宋大台村'],\n",
       "       [122.66, 41.34, 9.4, '朱家房镇'],\n",
       "       [122.62, 41.72, 9.4, '大黑岗子镇'],\n",
       "       [123.18, 42.35, 9.4, '丁家房镇'],\n",
       "       [123.31, 41.8, 9.3, '苗圃'],\n",
       "       [123.35, 42.12, 9.2, '石佛寺'],\n",
       "       [123.67, 41.92, 9.2, '棋盘山'],\n",
       "       [123.29, 41.84, 9.2, '五十六中学'],\n",
       "       [123.37, 41.83, 9.2, '崇山西路泵站'],\n",
       "       [123.34, 41.61, 9.2, '林盛街道四方台村'],\n",
       "       [123.35, 41.54, 9.2, '十里河街道柳三家子村'],\n",
       "       [123.47, 41.81, 9.1, '大东文化馆'],\n",
       "       [123.34, 41.82, 9.1, '铁西区政府'],\n",
       "       [123.13, 41.79, 9.1, '胡台镇'],\n",
       "       [122.49, 41.89, 9.1, '红旗乡'],\n",
       "       [122.86, 42.06, 9.1, '高台子镇'],\n",
       "       [123.65, 41.78, 9.1, '深井子街道'],\n",
       "       [123.15, 42.76, 9.1, '二牛所口镇'],\n",
       "       [122.6, 41.87, 9.1, '大红旗镇'],\n",
       "       [123.63, 41.69, 9.0, '柏叶基地'],\n",
       "       [123.43, 41.83, 9.0, '省政协'],\n",
       "       [122.97, 42.63, 9.0, '柳树屯乡'],\n",
       "       [122.61, 41.97, 9.0, '卢家屯乡'],\n",
       "       [123.28, 42.45, 9.0, '龙山街道'],\n",
       "       [123.26, 41.85, 9.0, '大兴学校'],\n",
       "       [123.44, 41.76, 9.0, '科普公园'],\n",
       "       [122.98, 41.69, 8.9, '杨士岗镇'],\n",
       "       [123.35, 41.79, 8.9, '沈阳四中'],\n",
       "       [123.4, 41.58, 8.9, '沙河街道'],\n",
       "       [123.32, 41.81, 8.9, '铁西体育场'],\n",
       "       [123.41, 41.68, 8.9, '大羊安社区'],\n",
       "       [123.36, 41.76, 8.9, '滑翔小学'],\n",
       "       [123.41, 41.89, 8.9, '十一中学'],\n",
       "       [123.25, 41.76, 8.8, '世纪高尔夫'],\n",
       "       [123.38, 41.58, 8.8, '林盛街道北乱村'],\n",
       "       [123.35, 41.59, 8.8, '林盛煤矿'],\n",
       "       [123.28, 42.53, 8.7, '慈恩寺乡汪家沟村'],\n",
       "       [123.44, 41.82, 8.7, '皇姑区政府'],\n",
       "       [123.4, 41.83, 8.7, '一二Ｏ中学'],\n",
       "       [123.19, 42.41, 8.7, '双台子乡'],\n",
       "       [123.46, 41.82, 8.7, '大东广场泵站'],\n",
       "       [123.35, 41.88, 8.7, '造化街道'],\n",
       "       [123.47, 41.81, 8.7, '沈阳五中'],\n",
       "       [122.88, 41.66, 8.6, '刘二堡镇'],\n",
       "       [123.71, 41.84, 8.6, '汪家街道'],\n",
       "       [123.44, 41.72, 8.6, '浑南二小'],\n",
       "       [123.15, 41.69, 8.5, '大潘街道'],\n",
       "       [123.32, 41.78, 8.5, '长客西站'],\n",
       "       [123.4, 42.63, 8.5, '三台子沉陷区'],\n",
       "       [123.41, 41.73, 8.5, '仙岛'],\n",
       "       [123.38, 41.61, 8.5, '沙河街道官屯村'],\n",
       "       [123.26, 41.98, 8.5, '平罗街道'],\n",
       "       [123.39, 41.74, 8.5, '长白岛'],\n",
       "       [123.68, 41.57, 8.4, '白清姚千街道'],\n",
       "       [123.16, 41.63, 8.4, '沈水街道'],\n",
       "       [123.36, 42.22, 8.4, '依牛堡子镇'],\n",
       "       [123.46, 41.72, 8.4, '市气象局'],\n",
       "       [123.47, 41.74, 8.4, '浑南一小'],\n",
       "       [123.32, 41.58, 8.3, '林盛街道史三家子村'],\n",
       "       [123.28, 41.54, 8.3, '八一红菱街道烟台村'],\n",
       "       [123.71, 41.58, 8.2, '白清姚千街道邓家沟村'],\n",
       "       [123.46, 41.83, 8.2, '北塔泵站'],\n",
       "       [123.4, 41.9, 8.2, '师大附小'],\n",
       "       [123.38, 41.6, 8.1, '沙河街道河北村'],\n",
       "       [123.35, 41.6, 8.1, '林盛街道'],\n",
       "       [123.41, 41.81, 8.1, '十二线'],\n",
       "       [123.42, 41.88, 8.1, '三台子一小'],\n",
       "       [123.42, 41.84, 8.1, '北陵公园泵站'],\n",
       "       [123.49, 41.81, 8.0, '东塔公园'],\n",
       "       [123.48, 41.76, 8.0, '文翠电器中心'],\n",
       "       [123.31, 41.8, 8.0, '苗圃泵站'],\n",
       "       [123.95, 41.68, 8.0, '沈阳南站'],\n",
       "       [123.21, 42.88, 8.0, '小城子镇'],\n",
       "       [123.42, 41.8, 8.0, '北市场'],\n",
       "       [122.84, 41.61, 7.9, '潘家堡镇'],\n",
       "       [122.7, 41.51, 7.9, '辽中'],\n",
       "       [123.68, 41.68, 7.9, '祝家街道'],\n",
       "       [123.57, 41.72, 7.9, '施家寨社区'],\n",
       "       [123.43, 42.02, 7.8, '财落街道'],\n",
       "       [123.39, 41.8, 7.8, '沈阳火车站'],\n",
       "       [123.42, 41.75, 7.8, '三好桥'],\n",
       "       [122.78, 41.42, 7.8, '蒲东街道'],\n",
       "       [122.48, 42.06, 7.8, '姚堡乡'],\n",
       "       [123.38, 42.32, 7.8, '大孤家子镇'],\n",
       "       [123.31, 41.54, 7.8, '红菱煤矿'],\n",
       "       [123.44, 41.79, 7.8, '十七中学'],\n",
       "       [123.31, 42.66, 7.8, '东关街道泡子沿村'],\n",
       "       [123.47, 41.82, 7.7, '沈阳大学'],\n",
       "       [123.05, 41.63, 7.7, '新民屯镇'],\n",
       "       [122.96, 41.58, 7.7, '四方台镇'],\n",
       "       [123.32, 41.77, 7.6, '仙女湖公园'],\n",
       "       [123.49, 41.75, 7.6, '长青泵站'],\n",
       "       [123.48, 41.82, 7.6, '沈阳东站'],\n",
       "       [123.36, 41.79, 7.6, '勋望小学'],\n",
       "       [123.48, 41.86, 7.6, '素质教育学校'],\n",
       "       [123.42, 42.55, 7.6, '孟家镇'],\n",
       "       [123.23, 41.89, 7.6, '马三家街道'],\n",
       "       [123.37, 41.51, 7.6, '十里河街道'],\n",
       "       [122.69, 42.22, 7.6, '于家窝堡乡'],\n",
       "       [123.49, 41.79, 7.6, '沈阳一中'],\n",
       "       [123.08, 41.66, 7.6, '彰驿站街道'],\n",
       "       [123.7, 42.05, 7.5, '马刚街道中寺村'],\n",
       "       [123.47, 41.87, 7.5, '文官街道'],\n",
       "       [123.35, 42.06, 7.5, '兴隆台街道'],\n",
       "       [123.43, 41.79, 7.4, '实验小学'],\n",
       "       [123.19, 42.5, 7.4, '四家子乡'],\n",
       "       [123.32, 41.66, 7.4, '苏家屯'],\n",
       "       [123.18, 42.58, 7.4, '西关屯乡'],\n",
       "       [123.57, 41.82, 7.4, '沈阳农业大学'],\n",
       "       [123.38, 41.76, 7.4, '工农桥'],\n",
       "       [123.52, 41.81, 7.4, '东陵街道'],\n",
       "       [123.02, 42.36, 7.3, '秀水河子镇'],\n",
       "       [123.38, 41.7, 7.3, '九洲社区'],\n",
       "       [123.61, 41.64, 7.3, '王士兰社区'],\n",
       "       [123.33, 42.67, 7.3, '东关街道小城子村'],\n",
       "       [123.4, 42.49, 7.3, '法库'],\n",
       "       [122.75, 41.59, 7.3, '养士堡镇'],\n",
       "       [123.51, 41.7, 7.2, '营城子社区'],\n",
       "       [123.44, 41.49, 7.2, '十里河街道大沟村'],\n",
       "       [123.4, 42.66, 7.2, '东关街道拉马屯村'],\n",
       "       [123.4, 42.42, 7.2, '十间房镇'],\n",
       "       [123.52, 41.81, 7.2, '八家子泵站'],\n",
       "       [123.45, 41.73, 7.1, '机场路泵站'],\n",
       "       [123.04, 41.56, 7.1, '长滩镇'],\n",
       "       [123.31, 41.79, 7.1, '工人村街道'],\n",
       "       [123.49, 41.67, 7.1, '莫子山公园'],\n",
       "       [123.56, 42.01, 7.0, '清水台街道中五旗村'],\n",
       "       [123.38, 41.78, 7.0, '南八桥'],\n",
       "       [123.58, 41.85, 7.0, '英达社区'],\n",
       "       [123.46, 41.77, 7.0, '27中学'],\n",
       "       [123.37, 41.75, 6.9, '阳光一百'],\n",
       "       [123.45, 41.81, 6.9, '杏坛小学'],\n",
       "       [123.47, 41.68, 6.9, '全运村'],\n",
       "       [123.39, 41.93, 6.8, '正良街道'],\n",
       "       [123.36, 42.02, 6.8, '尹家街道'],\n",
       "       [123.45, 42.32, 6.8, '冯贝堡乡'],\n",
       "       [123.41, 41.72, 6.8, '志成中学'],\n",
       "       [123.52, 42.16, 6.6, '黄家街道大丁村'],\n",
       "       [123.36, 42.74, 6.6, '康平县水利局'],\n",
       "       [123.35, 42.67, 6.6, '东关街道梁家屯村'],\n",
       "       [123.35, 42.81, 6.6, '康平'],\n",
       "       [122.88, 41.51, 6.6, '茨榆坨街道'],\n",
       "       [123.51, 41.73, 6.5, '沈阳'],\n",
       "       [123.58, 41.52, 6.4, '马耳山村'],\n",
       "       [123.3, 41.61, 6.4, '八一红菱街道官立村'],\n",
       "       [123.58, 42.0, 6.4, '清水台街道东五旗村'],\n",
       "       [123.49, 42.77, 6.3, '两家子乡'],\n",
       "       [123.6, 42.07, 6.3, '清水台街道前屯村'],\n",
       "       [123.36, 42.67, 6.2, '东关街道姜家窝堡村'],\n",
       "       [123.51, 41.57, 6.2, '陈相街道'],\n",
       "       [123.48, 42.85, 6.2, '北四家子乡'],\n",
       "       [123.67, 42.05, 6.0, '马刚街道苇塘沟村'],\n",
       "       [123.34, 42.73, 5.9, '滨湖综合楼'],\n",
       "       [122.58, 42.14, 5.9, '周坨子镇'],\n",
       "       [123.61, 41.96, 5.9, '辉山街道'],\n",
       "       [122.64, 41.25, 5.8, '于家房镇'],\n",
       "       [123.62, 42.6, 5.8, '和平乡'],\n",
       "       [122.87, 41.47, 5.7, '肖寨门镇'],\n",
       "       [123.52, 41.66, 5.7, '桃仙街道'],\n",
       "       [123.6, 42.04, 5.6, '清水台街道闫三家村'],\n",
       "       [123.63, 42.07, 5.6, '怪坡景区'],\n",
       "       [123.49, 42.67, 5.6, '郝官屯镇'],\n",
       "       [123.62, 42.55, 5.5, '柏家沟镇'],\n",
       "       [123.51, 41.94, 5.4, '虎石台街道'],\n",
       "       [123.61, 42.04, 5.4, '清水台街道前腰堡村'],\n",
       "       [123.07, 41.78, 5.3, '法哈牛镇'],\n",
       "       [123.53, 42.04, 5.3, '沈北新区'],\n",
       "       [123.35, 41.76, 5.3, '宏城社区'],\n",
       "       [123.53, 42.93, 5.2, '北三家子街道'],\n",
       "       [123.48, 41.72, 5.2, '教场泵站'],\n",
       "       [123.57, 42.05, 5.2, '新城子街道大洋河村'],\n",
       "       [123.66, 42.58, 5.0, '刘小船村'],\n",
       "       [123.01, 42.7, 5.0, '张强镇'],\n",
       "       [123.67, 42.52, 4.9, '柏家沟镇党家街村'],\n",
       "       [123.62, 42.08, 4.8, '马刚街道拥屯村'],\n",
       "       [123.3, 41.78, 4.7, '羊吉水产市场'],\n",
       "       [123.54, 41.6, 4.7, '佟沟街道'],\n",
       "       [123.55, 41.62, 4.6, '佟沟街道胜利村'],\n",
       "       [123.38, 42.94, 4.0, '海洲乡'],\n",
       "       [123.58, 41.91, 3.5, '农业高新区'],\n",
       "       [123.45, 41.82, 3.5, '都市绿洲'],\n",
       "       [122.7, 41.45, 3.3, '六间房镇'],\n",
       "       [123.39, 41.56, 3.3, '林盛街道长兴甸村'],\n",
       "       [123.66, 41.93, 3.2, '棋盘山秀湖'],\n",
       "       [123.08, 41.69, 3.1, '高花街道'],\n",
       "       [123.44, 41.83, 3.1, '省人大'],\n",
       "       [122.63, 41.6, 2.8, '满都户镇'],\n",
       "       [123.37, 41.76, 2.8, '滑翔公园'],\n",
       "       [123.42, 41.82, 1.9, '沈阳北站'],\n",
       "       [123.35, 42.71, 1.8, '东关街道'],\n",
       "       [122.76, 41.56, 1.2, '蒲西街道'],\n",
       "       [123.58, 42.03, 0.8, '清水台街道小洋河村'],\n",
       "       [122.55, 41.59, 0.0, '牛心坨镇'],\n",
       "       [123.22, 42.06, 0.0, '罗家房镇']], dtype=object)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.values #将DataFrame数据类型转为Numpy类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      122.94\n",
       "1      123.04\n",
       "2      123.23\n",
       "3      123.11\n",
       "4      122.89\n",
       "        ...  \n",
       "234    123.35\n",
       "235    122.76\n",
       "236    123.58\n",
       "237    122.55\n",
       "238    123.22\n",
       "Name: 经度, Length: 239, dtype: float64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = df['经度'] #获取某列数据\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>经度</th>\n",
       "      <th>纬度</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>122.94</td>\n",
       "      <td>42.48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>123.04</td>\n",
       "      <td>41.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>123.23</td>\n",
       "      <td>42.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>123.11</td>\n",
       "      <td>42.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>122.89</td>\n",
       "      <td>42.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>234</th>\n",
       "      <td>123.35</td>\n",
       "      <td>42.71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>235</th>\n",
       "      <td>122.76</td>\n",
       "      <td>41.56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>236</th>\n",
       "      <td>123.58</td>\n",
       "      <td>42.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>237</th>\n",
       "      <td>122.55</td>\n",
       "      <td>41.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>238</th>\n",
       "      <td>123.22</td>\n",
       "      <td>42.06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>239 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         经度     纬度\n",
       "0    122.94  42.48\n",
       "1    123.04  41.97\n",
       "2    123.23  42.63\n",
       "3    123.11  42.08\n",
       "4    122.89  42.67\n",
       "..      ...    ...\n",
       "234  123.35  42.71\n",
       "235  122.76  41.56\n",
       "236  123.58  42.03\n",
       "237  122.55  41.59\n",
       "238  123.22  42.06\n",
       "\n",
       "[239 rows x 2 columns]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2=df[['经度','纬度']] # 提取df中的一列或者几列值\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.set_index('Name')  设置df中某一列为索引"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
